package com.frxuexi.shop2307.shop

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import androidx.recyclerview.widget.LinearLayoutManager
import com.alibaba.android.arouter.facade.annotation.Route
import com.frxuexi.lib_base.entity.ProductBeanItem
import com.frxuexi.lib_base.mvvm.BaseActivity
import com.frxuexi.shop2307.R
import com.frxuexi.shop2307.adapter.ShopAdapter
import com.frxuexi.shop2307.databinding.ActivityShopLoveBinding
import dagger.hilt.android.AndroidEntryPoint

@Route(path = "/app/ShopLoveActivity")
@AndroidEntryPoint
class ShopLoveActivity : BaseActivity<ActivityShopLoveBinding,ShopViewModel>() {
    val shopAdapter by lazy { ShopAdapter() }
    val list= mutableListOf<ProductBeanItem>()
    override fun initData() {
        vm.prosData.observe(this){
            it.forEach {
                list.add(ProductBeanItem(id=it.id!!, storeName = it.storeName, image = it.image, price = it.price, otPrice = it.otPrice))
            }
            shopAdapter.apply {
                addData(list)
                notifyDataSetChanged()
            }
        }
    }

    override fun initView() {
        binding.loveRv.apply {
            adapter=shopAdapter
            layoutManager=LinearLayoutManager(this@ShopLoveActivity)
        }
        vm.getProsLove()
    }

}